﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class Duty : IAccessible<T_Duty, Duty>, ILogicEntity<T_Duty, Duty>
    {
        #region
        public int Id { get; set; }
        /// <summary>
        /// yyyy-MM-dd
        /// </summary>
        public string Date { get; set; }
        public string Content { get; set; }
        public DateTime RecordDate { get; set; }
        public string Creator { get; set; }
        #endregion

        protected override void Covariant(T_Duty model)
        {
            if (model != null)
            {
                this.Content = model.Content;
                this.Creator = model.Creator;
                this.Date = model.Date;
                this.Id = model.Id;
                this.RecordDate = model.RecordDate;
            }
        }

        protected override T_Duty Inverter(Duty model)
        {
            if (model != null)
            {
                return new T_Duty()
                {
                    Content = model.Content,
                    Creator = model.Creator,
                    Date = model.Date,
                    Id = model.Id,
                    RecordDate = model.RecordDate
                };
            }
            return null;
        }

        public Duty Set(T_Duty dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
